/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.edu.upc.dew.discoteca.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author elvis
 */
@Entity
@Table(name = "persona")
@NamedQueries({@NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"), @NamedQuery(name = "Persona.findByCodigo", query = "SELECT p FROM Persona p WHERE p.codigo = :codigo"), @NamedQuery(name = "Persona.findByNombre", query = "SELECT p FROM Persona p WHERE p.nombre = :nombre"), @NamedQuery(name = "Persona.findByApellido", query = "SELECT p FROM Persona p WHERE p.apellido = :apellido"), @NamedQuery(name = "Persona.findByEmail", query = "SELECT p FROM Persona p WHERE p.email = :email"), @NamedQuery(name = "Persona.findByUsuario", query = "SELECT p FROM Persona p WHERE p.usuario = :usuario"), @NamedQuery(name = "Persona.findByClave", query = "SELECT p FROM Persona p WHERE p.clave = :clave"), @NamedQuery(name = "Persona.findByTipoUsuario", query = "SELECT p FROM Persona p WHERE p.tipoUsuario = :tipoUsuario")})
public class Persona implements Serializable {
   private static final long serialVersionUID = 1L;
   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Basic(optional = false)
   @Column(name = "codigo")
   private Integer codigo;
   @Column(name = "nombre")
   private String nombre;
   @Column(name = "apellido")
   private String apellido;
   @Column(name = "email")
   private String email;
   @Column(name = "usuario")
   private String usuario;
   @Column(name = "clave")
   private String clave;
   @Column(name = "tipoUsuario")
   private Integer tipoUsuario;
   @OneToMany(cascade = CascadeType.ALL, mappedBy = "codigoPersona")
   private List<Lista> listaList;

   public Persona() {
   }

   public Persona(Integer codigo) {
      this.codigo = codigo;
   }

   public Integer getCodigo() {
      return codigo;
   }

   public void setCodigo(Integer codigo) {
      this.codigo = codigo;
   }

   public String getNombre() {
      return nombre;
   }

   public void setNombre(String nombre) {
      this.nombre = nombre;
   }

   public String getApellido() {
      return apellido;
   }

   public void setApellido(String apellido) {
      this.apellido = apellido;
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   public String getUsuario() {
      return usuario;
   }

   public void setUsuario(String usuario) {
      this.usuario = usuario;
   }

   public String getClave() {
      return clave;
   }

   public void setClave(String clave) {
      this.clave = clave;
   }

   public Integer getTipoUsuario() {
      return tipoUsuario;
   }

   public void setTipoUsuario(Integer tipoUsuario) {
      this.tipoUsuario = tipoUsuario;
   }

   public List<Lista> getListaList() {
      return listaList;
   }

   public void setListaList(List<Lista> listaList) {
      this.listaList = listaList;
   }

   @Override
   public int hashCode() {
      int hash = 0;
      hash += (codigo != null ? codigo.hashCode() : 0);
      return hash;
   }

   @Override
   public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Persona)) {
         return false;
      }
      Persona other = (Persona) object;
      if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
         return false;
      }
      return true;
   }

   @Override
   public String toString() {
      return "pe.edu.upc.dew.discoteca.model2.Persona[codigo=" + codigo + "]";
   }

}
